package com.oig.sys.workflow.runner;

import com.oig.sys.workflow.schedule.CronJobManager;
import com.oig.sys.workflow.service.ITbCronJobService;
import com.oig.sys.workflow.vo.CronJobVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Slf4j
@RequiredArgsConstructor
public class TaskRunner implements ApplicationRunner {


    private final ITbCronJobService cronJobService;
    private final CronJobManager cronJobManager;


    @Override
    public void run(ApplicationArguments args)  {
        List<CronJobVo> cronJobVoList = cronJobService.getAllEnableJob();
        cronJobVoList.forEach(cronJobManager::startJob);
    }


}
